package com.hexinfo.dmpro.data.transfer.common.model;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.validation.annotation.Validated;

import java.util.Date;

@Data
@Validated
@TableName("TD_AGENT_INFO")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AGENT 配置信息")
public class AgentInfo extends Model<AgentInfo> {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId(type = IdType.ASSIGN_UUID)
    @ApiModelProperty(value = "ID")
    private String id;

    @ApiModelProperty(value = "所属集群标识")
    private String clusterCode;

    @ApiModelProperty(value = "AGENT主机")
    private String agentHost;

    @ApiModelProperty(value = "AGENT端口")
    private Integer agentPort;

    @ApiModelProperty(value = "AGETN并发数")
    private Integer maxPoolSize;

    @ApiModelProperty(value = "AGETN最新心跳时间")
    private String sendTime;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
    private Date lastUpdateTime;

    public String getDevDataExportHttpUrl() {
        return "http://" + agentHost + ":" + agentPort + "/api/hive/export";
    }

    public String getDevDataImportHttpUrl() {
        return "http://" + agentHost + ":" + agentPort + "/api/hive/import";
    }

    public String getFtpListFilesHttpUrl(){
        return "http://" + agentHost + ":" + agentPort + "/api/ftp/listFiles";
    }

    public String getFtpReadFileHttpUrl(){
        return "http://" + agentHost + ":" + agentPort + "/api/ftp/readFile";
    }

    public String getAgentKey() {
        return agentHost + ":" + agentPort;
    }
}
